function [cc] = CalibrateCameraAffine( Xreal, xImg )
% xi = Ximg;
% Xi = Xreal;
% 
% [xImg  xmean ymean scalef] = normalizeImgCoord(xImg);
% [Xreal  xmean3 ymean3 zmean3 scalef3] = normalize3DCoord(Xreal);
% 

N = size(xImg,2);
M = zeros(2 * N, 8);
xobs = xImg(1,:);
yobs = xImg(2,:);
xx = upsample(xobs,2);
yy = upsample(yobs,2);
yy(2:end) = yy(1:end-1); yy(1) = 0;
RHS = xx' + yy';

for n = 1:2:2*N
   k = ceil(n/2);
   M(n,1:4) = Xreal(1:4,k)';
   M(n,5:8) = zeros(1,4);
   %M(n,9:11) = -xobs(k)*Xreal(1:3,k); 
   
   M(n+1,1:4) = zeros(1,4);
   M(n+1,5:8) = Xreal(1:4,k)';
   %M(n+1,9:11) = -yobs(k)*Xreal(1:3,k);
    
end

cc = M \ RHS;
cc = [cc; zeros(3,1)];
breakher  = 1;